package com.rd.student.ruanjian.class3.gaochenxi.LianXi3.NumberFour;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
//进阶版2
public class NumberFourFour {
   public static void main(String[] args) {
      ExecutorService service = Executors.newSingleThreadExecutor();
      ArrayList<String> arrayList = new ArrayList<>(3);
      service.execute(new Runnable() {
         //能把三个放一堆一起过
         @Override
         public void run() {
            int[] ai = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
            String[] ac = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"};
            for (int i = 0; i < ai.length - 1; i++) {
               if ((i + 1) % 3 == 0) {//3,6,9
                  arrayList.add(ac[i]);
                  int j = 0;
                  System.out.print(arrayList.get(j) + arrayList.get(j + 1) + arrayList.get(j + 2) + "一起通过山洞,");
                  if ((i + 3) <= ac.length) {
                     System.out.println("正在通知" + ac[i + 1] + ac[i + 2] + ac[i + 3]);
                  }
                  arrayList.removeAll(arrayList);
               } else {
                  arrayList.add(ac[i]);
               }
            }
            System.out.println(ac[ac.length - 1] + "正在通过山洞");
            System.out.println("全部成员已通过山洞");
         }
      });
   }
}
